/**
 * <copyright>
 * </copyright>
 *

 */
package it.unibo.iss.domotica.domoticDsl.impl;

import it.unibo.iss.domotica.domoticDsl.DomoticDslPackage;
import it.unibo.iss.domotica.domoticDsl.Elettrodomestico;
import it.unibo.iss.domotica.domoticDsl.Sensor;

import org.eclipse.emf.common.notify.Notification;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.MinimalEObjectImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Sensor</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link it.unibo.iss.domotica.domoticDsl.impl.SensorImpl#getElettrodomestico <em>Elettrodomestico</em>}</li>
 *   <li>{@link it.unibo.iss.domotica.domoticDsl.impl.SensorImpl#getMinConsumption <em>Min Consumption</em>}</li>
 *   <li>{@link it.unibo.iss.domotica.domoticDsl.impl.SensorImpl#getMaxConsumption <em>Max Consumption</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class SensorImpl extends MinimalEObjectImpl.Container implements Sensor
{
  /**
   * The cached value of the '{@link #getElettrodomestico() <em>Elettrodomestico</em>}' reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getElettrodomestico()
   * @generated
   * @ordered
   */
  protected Elettrodomestico elettrodomestico;

  /**
   * The default value of the '{@link #getMinConsumption() <em>Min Consumption</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getMinConsumption()
   * @generated
   * @ordered
   */
  protected static final String MIN_CONSUMPTION_EDEFAULT = null;

  /**
   * The cached value of the '{@link #getMinConsumption() <em>Min Consumption</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getMinConsumption()
   * @generated
   * @ordered
   */
  protected String minConsumption = MIN_CONSUMPTION_EDEFAULT;

  /**
   * The default value of the '{@link #getMaxConsumption() <em>Max Consumption</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getMaxConsumption()
   * @generated
   * @ordered
   */
  protected static final String MAX_CONSUMPTION_EDEFAULT = null;

  /**
   * The cached value of the '{@link #getMaxConsumption() <em>Max Consumption</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getMaxConsumption()
   * @generated
   * @ordered
   */
  protected String maxConsumption = MAX_CONSUMPTION_EDEFAULT;

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected SensorImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass()
  {
    return DomoticDslPackage.Literals.SENSOR;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Elettrodomestico getElettrodomestico()
  {
    if (elettrodomestico != null && elettrodomestico.eIsProxy())
    {
      InternalEObject oldElettrodomestico = (InternalEObject)elettrodomestico;
      elettrodomestico = (Elettrodomestico)eResolveProxy(oldElettrodomestico);
      if (elettrodomestico != oldElettrodomestico)
      {
        if (eNotificationRequired())
          eNotify(new ENotificationImpl(this, Notification.RESOLVE, DomoticDslPackage.SENSOR__ELETTRODOMESTICO, oldElettrodomestico, elettrodomestico));
      }
    }
    return elettrodomestico;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Elettrodomestico basicGetElettrodomestico()
  {
    return elettrodomestico;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setElettrodomestico(Elettrodomestico newElettrodomestico)
  {
    Elettrodomestico oldElettrodomestico = elettrodomestico;
    elettrodomestico = newElettrodomestico;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, DomoticDslPackage.SENSOR__ELETTRODOMESTICO, oldElettrodomestico, elettrodomestico));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public String getMinConsumption()
  {
    return minConsumption;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setMinConsumption(String newMinConsumption)
  {
    String oldMinConsumption = minConsumption;
    minConsumption = newMinConsumption;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, DomoticDslPackage.SENSOR__MIN_CONSUMPTION, oldMinConsumption, minConsumption));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public String getMaxConsumption()
  {
    return maxConsumption;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setMaxConsumption(String newMaxConsumption)
  {
    String oldMaxConsumption = maxConsumption;
    maxConsumption = newMaxConsumption;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, DomoticDslPackage.SENSOR__MAX_CONSUMPTION, oldMaxConsumption, maxConsumption));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType)
  {
    switch (featureID)
    {
      case DomoticDslPackage.SENSOR__ELETTRODOMESTICO:
        if (resolve) return getElettrodomestico();
        return basicGetElettrodomestico();
      case DomoticDslPackage.SENSOR__MIN_CONSUMPTION:
        return getMinConsumption();
      case DomoticDslPackage.SENSOR__MAX_CONSUMPTION:
        return getMaxConsumption();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case DomoticDslPackage.SENSOR__ELETTRODOMESTICO:
        setElettrodomestico((Elettrodomestico)newValue);
        return;
      case DomoticDslPackage.SENSOR__MIN_CONSUMPTION:
        setMinConsumption((String)newValue);
        return;
      case DomoticDslPackage.SENSOR__MAX_CONSUMPTION:
        setMaxConsumption((String)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case DomoticDslPackage.SENSOR__ELETTRODOMESTICO:
        setElettrodomestico((Elettrodomestico)null);
        return;
      case DomoticDslPackage.SENSOR__MIN_CONSUMPTION:
        setMinConsumption(MIN_CONSUMPTION_EDEFAULT);
        return;
      case DomoticDslPackage.SENSOR__MAX_CONSUMPTION:
        setMaxConsumption(MAX_CONSUMPTION_EDEFAULT);
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case DomoticDslPackage.SENSOR__ELETTRODOMESTICO:
        return elettrodomestico != null;
      case DomoticDslPackage.SENSOR__MIN_CONSUMPTION:
        return MIN_CONSUMPTION_EDEFAULT == null ? minConsumption != null : !MIN_CONSUMPTION_EDEFAULT.equals(minConsumption);
      case DomoticDslPackage.SENSOR__MAX_CONSUMPTION:
        return MAX_CONSUMPTION_EDEFAULT == null ? maxConsumption != null : !MAX_CONSUMPTION_EDEFAULT.equals(maxConsumption);
    }
    return super.eIsSet(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public String toString()
  {
    if (eIsProxy()) return super.toString();

    StringBuffer result = new StringBuffer(super.toString());
    result.append(" (minConsumption: ");
    result.append(minConsumption);
    result.append(", maxConsumption: ");
    result.append(maxConsumption);
    result.append(')');
    return result.toString();
  }

} //SensorImpl
